#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > ccsdr12pt_ne_f12.info <<'%EOF%'
   ccsdr12pt_ne_f12
   -----------
   Molecule:         Ne 
   Wave Function:    CCSD(R12)(T)/A1/B / aug-cc-pVDZ + aug-cc-pVDZ
   Test Purpose:     Check CCSD(R12)(T)/A1/B method with auxiliary basis 
                     and correlation factor F12
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > ccsdr12pt_ne_f12.mol <<'%EOF%'
INTGRL
Ne                                                                              
aug-cc-pVDZ + aug-cc-pVDZ as auxbasis
    2    0  
 1     10.    1    3    3    2    1
Ne      0.0000000000000     0.0000000000000     0.0000000000000
H   9    1
    17880.0000000000        0.0007380000     
     2683.0000000000        0.0056770000     
      611.5000000000        0.0288830000     
      173.5000000000        0.1085400000     
       56.6400000000        0.2909070000     
       20.4200000000        0.4483240000     
        7.8100000000        0.2580260000     
        1.6530000000        0.0150630000     
        0.4869000000       -0.0021000000     
H   9    1
    17880.0000000000       -0.0001720000  
     2683.0000000000       -0.0013570000  
      611.5000000000       -0.0067370000  
      173.5000000000       -0.0276630000  
       56.6400000000       -0.0762080000  
       20.4200000000       -0.1752270000  
        7.8100000000       -0.1070380000  
        1.6530000000        0.5670500000  
        0.4869000000        0.5652160000  
F   2    0
        0.4869000000          
        0.1230000000          
H   4    1
       28.3900000000        0.0460870000     
        6.2700000000        0.2401810000     
        1.6950000000        0.5087440000     
        0.4317000000        0.4556600000     
F   2    0
        0.4317000000        
        0.1064000000        
F   2    0
        2.2020000000      
        0.6310000000      
 2     10.    1    3    3    2    1
Ne      0.0000000000000     0.0000000000000     0.0000000000000
H   9    1
    17880.0000000000        0.0007380000     
     2683.0000000000        0.0056770000     
      611.5000000000        0.0288830000     
      173.5000000000        0.1085400000     
       56.6400000000        0.2909070000     
       20.4200000000        0.4483240000     
        7.8100000000        0.2580260000     
        1.6530000000        0.0150630000     
        0.4869000000       -0.0021000000     
H   9    1
    17880.0000000000       -0.0001720000  
     2683.0000000000       -0.0013570000  
      611.5000000000       -0.0067370000  
      173.5000000000       -0.0276630000  
       56.6400000000       -0.0762080000  
       20.4200000000       -0.1752270000  
        7.8100000000       -0.1070380000  
        1.6530000000        0.5670500000  
        0.4869000000        0.5652160000  
F   2    0
        0.4869000000          
        0.1230000000          
H   4    1
       28.3900000000        0.0460870000     
        6.2700000000        0.2401810000     
        1.6950000000        0.5087440000     
        0.4317000000        0.4556600000     
F   2    0
        0.4317000000        
        0.1064000000        
F   2    0
        2.2020000000      
        0.6310000000      
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > ccsdr12pt_ne_f12.dal <<'%EOF%'

**DALTON INPUT
.RUN WAVE FUNCTION
*MOLBAS
.R12AUX
**INTEGRALS
.R12GTG
 1
 1.0 0.0
**WAVE FUNCTION
.CC
*ORBITAL INPUT
.MOSTART
 H1DIAG
*SCF IN  
.THRESH
 1.0D-12
*CC INPUT
.CC(T)
.PRINT
 5   
.FROIMP
  1 
  0 
.THRENR
 1.0D-12
.MAX IT
 300
*R12 INPUT
.CC2
 1B
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >ccsdr12pt_ne_f12.check
cat >>ccsdr12pt_ne_f12.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi


#           Total SCF   energy:                  -128.4963497305
#           Total MP2-R12/B energy:              -128.7979375063
#           Total CCSD(R12)/B energy:            -128.7914778365


#                    Perturbative triples corrections
#                    --------------------------------

#           The E4 doubles and triples:            -0.0030003831
#           The E5 singles and triples:             0.0002408764

#           Total CCSD(R12)(T)/B  energy:        -128.7942373432


CRIT1=`$GREP "Total SCF   energy: * \-128\.4963497305" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=2
ERROR[1]="SCF ENERGY NOT CORRECT"
CRIT2=`$GREP "Total MP2-R12/B energy: * \-128\.7979375063" $log | wc -l`
TEST[2]=`expr	$CRIT2`
CTRL[2]=2
ERROR[2]="MP2-R12/B ENERGY NOT CORRECT"
CRIT3=`$GREP "Total CCSD\(R12\)/B energy: * \-128\.7914778365" $log | wc -l`
TEST[3]=`expr	$CRIT3`
CTRL[3]=2
ERROR[3]="CCSD(R12)/B ENERGY NOT CORRECT"
CRIT4=`$GREP "The E4 doubles and triples: * \-(\.0030003831|0\.0030003831)" $log | wc -l`
TEST[4]=`expr	$CRIT4`
CTRL[4]=2
ERROR[4]="E4 ENERGY NOT CORRECT"
CRIT5=`$GREP "The E5 singles and triples: *( |0)\.0002408764" $log | wc -l`
TEST[5]=`expr	$CRIT5`
CTRL[5]=2
ERROR[5]="E5 ENERGY NOT CORRECT"
CRIT6=`$GREP "Total CCSD\(R12\)\(T\)/B  energy: * \-128\.7942373432" $log | wc -l`
TEST[6]=`expr	$CRIT6`
CTRL[6]=2
ERROR[6]="CCSD(R12)(T) ENERGY NOT CORRECT"
#

PASSED=1
for i in 1 2 3 4 5 6
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
